<template>
  <div>
    <x-header :left-options="{showBack: true,preventGoBack:true,backText:currentStep === 0?'返回':''}"
              @on-click-back="goBack" theme=""
              class="queryHeader">{{staffInfoVisible ? addStallTitle : currentTitles[currentStep]}}
    </x-header>
    <!--基本信息处理-->
    <div v-if="!staffInfoVisible">
      <div v-if="currentStep === 0">
        <group label-width="8em">
          <selector :value-map="['value','text']" :direction="selectorDirection" title="业务来源"
                    v-model="form.bussSourceCode"
                    :options="bussSources" placeholder="请选择业务来源"></selector>
          <selector v-if="form.bussSourceCode === '1'" :value-map="['value','text']" :direction="selectorDirection"
                    title="中介机构名称"
                    v-model="form.intermediaryCode" placeholder="请选择中介机构"
                    :options="intermediaryNames"></selector>
          <x-input v-if="form.bussSourceCode === '1'" :text-align="xInputAlign" style="padding: 12px 15px;"
                   type="number" :is-type="rateRule" v-model="form.serviceRate" title="手续费比例(%)"
                   placeholder="请填写手续费比例"></x-input>
        </group>
        <group label-width="8em">
          <x-input :text-align="xInputAlign" style="padding: 12px 15px;" type="text" v-model="form.customName"
                   title="客户名称" placeholder="请填写客户名称" :max="50" :required="true"></x-input>
          <selector :value-map="['value','text']" :direction="selectorDirection" title="企业性质" placeholder="请选择企业性质"
                    v-model="form.grpNatureCode"
                    :options="grpNatures"></selector>
        </group>
        <group label-width="8em">
          <popup-picker style="padding: 2px 0;" title="所属行业" :data="grpTypeDatas" :columns="2" placeholder="请选择行业类型"
                        @on-change="onGrpTypeChange" :value-text-align="xInputAlign" v-model="form.grpType"
                        @on-show="openPicker"
                        show-name>
          </popup-picker>
        </group>
        <box gap="10px 10px">
          <x-button type="primary" class="positiveBtn" @click.native="basicNextStep">下一步</x-button>
        </box>
      </div>
      <!--人员信息采集-->
      <div v-if="currentStep === 1">
        <group label-width="8em">
          <x-input :text-align="xInputAlign" style="padding: 12px 15px;" placeholder="请填写参保人数"
                   type="number" v-model="form.insuredPeoples" title="准备参保人数" :is-type="insuredPeopleRule"></x-input>
          <x-input :text-align="xInputAlign" style="padding: 12px 15px;" placeholder="请填写平均年龄"
                   type="number" v-model="form.inAvage" :is-type="avAgeRule" title="在职平均年龄"></x-input>
        </group>
        <group label-width="8em">
          <x-switch title="60周岁以上人员" v-model="form.isSixtyPeopleFlag" @on-change="oldManSwitch"></x-switch>
          <x-input :text-align="xInputAlign" style="padding: 12px 15px;" placeholder="请填写高龄人数"
                   type="number" v-model="form.sixtyPeoples" title="60周岁以上人数" v-if="form.isSixtyPeopleFlag"></x-input>
          <x-input :text-align="xInputAlign" style="padding: 12px 15px;" placeholder="请填写最高年龄"
                   type="number" v-model="form.maxAge" title="最高年龄" :is-type="maxAgeRule"
                   v-if="form.isSixtyPeopleFlag"></x-input>
        </group>
        <group label-width="8em">
          <x-input :text-align="xInputAlign" style="padding: 12px 15px;" :is-type="positiveRule"
                   placeholder="请填写男员工人数"
                   type="number" v-model="form.males" title="男员工人数"></x-input>
          <x-input :text-align="xInputAlign" style="padding: 12px 15px;" :is-type="positiveRule"
                   placeholder="请填写女员工人数"
                   type="number" v-model="form.females" title="女员工人数"></x-input>
          <x-input :text-align="xInputAlign" style="padding: 12px 15px;" :is-type="positiveRule" placeholder="请填写配偶人数"
                   type="number" v-model="form.spouser" title="配偶人数"></x-input>
          <x-input :text-align="xInputAlign" style="padding: 12px 15px;" :is-type="positiveRule" placeholder="请填写子女人数"
                   type="number" v-model="form.children" title="子女人数"></x-input>
        </group>
        <group label-width="8em">
          <cell title="职业信息" is-link style="padding: 11px 15px;" @click.native="viewStaffInfo">
            <span slot="default">查看</span>
          </cell>
        </group>
        <box gap="10px 10px">
          <x-button type="primary" class="positiveBtn" @click.native="peopleNextStep">下一步</x-button>
        </box>
      </div>
      <!--既往投保信息-->
      <div v-if="currentStep === 2">
        <group label-width="8em">
          <x-input :text-align="xInputAlign" style="padding: 12px 15px;" placeholder="请填写原被保人"
                   type="text" v-model="form.preproposalCarp" title="原保险人"></x-input>
        </group>
        <group title="既往投保及理赔记录" label-width="11em">
          <x-input :text-align="xInputAlign" style="padding: 12px 15px;" placeholder="请输入既往赔付率"
                   type="number" v-model="form.rate" title="既往赔付率(%)"></x-input>
          <cell title="既往投保及理赔记录" style="padding: 11px 15px;" @click.native="viewClaimNote">
            <span slot="default">{{form.claimNote !== "" ? '记录查看' : '未填写信息'}}</span>
          </cell>
        </group>
        <group title="业务背景描述信息" label-width="8em">
          <cell title="业务背景" style="padding: 11px 15px;" @click.native="viewCompetePlan">
            <span slot="default">{{form.competePlan !== "" ? '背景查看' : '未填写信息'}}</span>
          </cell>
        </group>
        <box gap="10px 10px">
          <x-button type="primary" class="positiveBtn" @click.native="oldNextStep">下一步</x-button>
        </box>
      </div>
      <!--方案制定-->
      <div v-if="currentStep === 3">
        <group label-width="8em">
          <cell title="添加保险方案" is-link style="padding: 11px 15px;" @click.native="viewSchemes">
            <span slot="default">{{form.schemes.length > 0 ? '查看' : '新增'}}</span>
          </cell>
        </group>
        <group label-width="8em">
          <x-switch title="是否共保业务" v-model="form.coinsuranceFlag" @on-change="coinsuranceSwitch"></x-switch>
          <x-input v-if="form.coinsuranceFlag" :text-align="xInputAlign" style="padding: 12px 15px;"
                   placeholder="请输入共保公司名称"
                   type="text" v-model="form.coinsuranceCompany" title="共保公司"></x-input>
          <x-input v-if="form.coinsuranceFlag" :text-align="xInputAlign" style="padding: 12px 15px;"
                   placeholder="请输入承担份额"
                   type="number" v-model="form.companyAmnt" title="我司承担份额(%)"></x-input>
        </group>
        <box gap="10px 10px">
          <x-button type="primary" class="positiveBtn" @click.native="submitOrder">提交</x-button>
        </box>
      </div>
    </div>

    <!--职业信息界面-->
    <viewStaffInfo @hideStaffInfoPage="staffInfoVisible = false"
                   @updateVocations="updateVocations"
                   @clearSchemes="clearSchemes"
                   @error="showStaffErrorInfo"
                   :insuredNms="form.insuredPeoples"
                   :vocations="form.vocations" v-if="staffInfoVisible">
    </viewStaffInfo>
    <popup v-model="showToast" position="top" :show-mask="false">
      <div class="position-vertical-demo">
        {{toastTxt}}
      </div>
    </popup>
    <!--文本域信息界面-->
    <div v-transfer-dom>
      <popup v-model="showOldDetailInfo" height="100%">
        <div style="width: 100%;height: 100%">
          <x-header :left-options="{showBack: true,preventGoBack:true}" @on-click-back="showOldDetailInfo = false"
                    theme="">
            {{claimNoteFlag ? '既往投保及理赔记录' : '业务背景'}}
          </x-header>
          <group title="既往投保及理赔记录" v-if="claimNoteFlag">
            <x-textarea :max="300" placeholder="请填写详细信息" :show-counter="true" :height="150"
                        v-model="form.claimNote"></x-textarea>
          </group>
          <group title="业务背景描述" v-if="!claimNoteFlag">
            <x-textarea :max="300" placeholder="请填写详细信息" :show-counter="true" :height="150"
                        v-model="form.competePlan"></x-textarea>
          </group>
          <box gap="10px 10px">
            <x-button type="primary" @click.native="closeOldDetailPopup">完成</x-button>
          </box>
        </div>
      </popup>
    </div>
  </div>
</template>
<script>
  import {
    TransferDom,
    Group,
    Selector,
    XHeader,
    XInput,
    PopupPicker,
    Box,
    XButton,
    XSwitch,
    Cell,
    Popup,
    XTextarea
  } from 'Vux'
  import viewStaffInfo from './StaffList.vue'
  export default {
    directives: {
      TransferDom
    },
    components: {
      Popup,
      Group,
      Selector,
      XHeader,
      XInput,
      PopupPicker,
      Box,
      XButton,
      XSwitch,
      Cell,
      viewStaffInfo,
      XTextarea
    },
    data(){
      return {
        showOldDetailInfo: false,
        claimNoteFlag: false,
        selectorDirection: 'rtl',
        xInputAlign: 'right',
        showToast: false,
        toastTxt: "",
        ios: true,
        currentStep: 0,
        currentTitles: ['基本信息', '人员信息', '既往投保', '保险方案'],
        bussSources: [],
        intermediaryNames: [],
        grpNatures: [],
        grpTypeDatas: [],
        addStallTitle: "",
        staffInfoVisible: false,
        basicInfoFlag: false,
        ratePlaceholder: "请输入既往赔付率",
        currentGrpType: [],
        form: {
//          step1
          bussSourceCode: "",
          intermediaryCode: "",
          serviceRate: "",
          customName: "",
          grpNatureCode: "",
          grpType: [],
          grpTypeCode: "",
          bussinessTypeName: "",
          bussinessTypeCode: "",
//          step2
          insuredPeoples: "",
          inAvage: "",
          isSixtyPeopleFlag: false,
          maxAge: "",
          sixtyPeoples: "",
          males: "",
          females: "",
          spouser: "",
          children: "",
          vocations: [],
//          step3
          preproposalCarp: "",
          rate: "",
          claimNote: "",
          competePlan: "",
//          step4
          coinsuranceFlag: false,
          coinsuranceCompany: "",
          companyAmnt: "",
          schemes: []
        },
      }
    },
    //校验人数总和是否正确
    computed: {
      calcPeoples(){
        if (Number(this.form.insuredPeoples) === Number(this.form.males) +
          Number(this.form.females) + Number(this.form.spouser) + Number(this.form.children)) {
          return true
        } else {
          return false
        }
      }
    },
    //监听popup
    watch: {
      showToast (val) {
        if (val) {
          setTimeout(() => {
            this.showToast = false
          }, 1000)
        }
      }
    },
    methods: {
      //唤起toast提示
      vuxToast(info){
        this.showToast = true;
        this.toastTxt = info;
      },
      //基本工具UUid生成
      S4(){
        return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
      },
      getUUid(){
        let workNumber = this.$store.state.app.workNumber;
        return (this.S4() + this.S4() + "-" + this.S4() + "-" + this.S4() + "-" + this.S4() + "-" + this.S4() + this.S4() + this.S4() + "-" + workNumber);
      },
      //validate规则校验
      positiveRule(value){
        if (value < 0) {
          return {
            valid: false,
            msg: '请输入大于零的数值哦'
          }
        } else {
          if (value.split('.').length > 1) {
            return {
              valid: false,
              msg: '请输入合适的数值哦'
            }
          } else {
            return {
              valid: true
            }
          }
        }
      },
      rateRule(value){
        let flag = false;
        if (value > 0 && value < 91) {
          flag = true
        } else {
          flag = false
        }
        return {
          valid: flag,
          msg: '请输入1-90之间的数值'
        }
      },
      avAgeRule(value){
        if (value > 99) {
          return {
            valid: false,
            msg: '平均年龄不得超过99岁'
          }
        } else if (value < 0) {
          return {
            valid: false,
            msg: '请输入大于零的数值哦'
          }
        } else {
          return {
            valid: true
          }
        }
      },
      maxAgeRule(value){
        let val = Math.round(value);
        if (val > 99) {
          return {
            valid: false,
            msg: '最高年龄控制在99岁以内'
          }
        } else if (value < 60) {
          return {
            valid: false,
            msg: '最高年龄不得低于60岁'
          }
        } else {
          return {
            valid: true,
            msg: 'ok'
          }
        }
      },
      insuredPeopleRule(value){
        let val = Math.round(value);
        if (val < 3) {
          return {
            valid: false,
            msg: '参保人数不得低于3人'
          }
        } else {
          return {
            valid: true,
            msg: 'ok'
          }
        }
      },
      //基本信息下一步
      basicNextStep(){
        if (this.form.bussSourceCode === "") {
          this.vuxToast('请填写业务来源');
          return
        }
        if (this.form.bussSourceCode === "1" && this.form.serviceRate === "") {
          this.vuxToast('请填写手续费比例');
          return
        }
        if (this.form.customName === "") {
          this.vuxToast('请填写客户名称');
          return
        }
        if (this.form.grpNatureCode === "") {
          this.vuxToast('请选择企业性质');
          return
        }
        if (this.form.grpTypeCode.length === 0) {
          this.vuxToast('请选择行业信息');
        } else {
          this.currentStep++;
        }
      },
      //人员信息下一步
      peopleNextStep(){
        if (this.form.isSixtyPeopleFlag) {
          if (this.form.vocations.length > 0 && this.form.insuredPeoples !== "" && this.form.inAvage !== "" &&
            this.form.sixtyPeoples !== "" && this.form.maxAge >= 60 && this.form.maxAge < 100) {
            if (this.form.customName !== "") {
              if (this.form.rate === "") {
                this.getClaimRate()
              }
            } else {
              this.ratePlaceholder = "未填写客户名称无法查询"
            }
            this.currentStep++;
          } else {
            this.vuxToast('请补全相关信息');
            return
          }
        } else {
          if (this.form.vocations.length > 0 && this.form.insuredPeoples !== "" && this.form.inAvage !== "" && this.calcPeoples) {
            if (this.form.customName !== "") {
              if (this.form.rate === "") {
                this.getClaimRate()
              }
            } else {
              this.ratePlaceholder = "未填写客户名称无法查询"
            }
            this.currentStep++;
          } else {
            if (!this.calcPeoples) {
              this.vuxToast('投保人数不匹配');
            } else {
              this.vuxToast('请补全相关信息');
            }
            return
          }
        }
      },
      //既往投保信息下一步
      oldNextStep(){
        this.currentStep++;
      },
      //下一页脚标变化
      preStep(){
        if (this.currentStep > 0) {
          this.currentStep--;
        } else {
          this.currentStep = 0;
        }
      },
      //录入界面跳转主页
      goBack(){
        if (this.currentStep === 0) {
          this.$router.push({
            path: '/home'
          });
          this.$store.commit('CHANGE_TRANSITION', 'right')
        } else {
          if (this.staffInfoVisible) {
            this.staffInfoVisible = false
          } else {
            this.preStep()
          }
        }
      },
      //打开picker
      openPicker(){
        let grpType = this.form.grpType;
        if (grpType.length > 0) {
          this.currentGrpType = grpType
        } else {
          this.currentGrpType = []
        }
      },
      //更改、获取行业信息
      onGrpTypeChange(value){
        let originType = this.currentGrpType;
        if (value[1] === originType[1]) {
          return
        } else if (this.$store.state.app.vocations.length > 0) {
          let thus = this;
          this.$vux.confirm.show({
            theme: thus.ios ? 'ios' : 'android',
            title: '提示',
            content: '更改此项会删除对应职业信息相关类',
            confirmText: '继续',
            cancelText: '取消',
            onCancel () {
              thus.form.grpType = originType;
              thus.$vux.confirm.hide();
            },
            onConfirm () {
              if (value[1] === thus.form.bussinessTypeCode) {
                thus.$vux.confirm.hide();
              } else {
                thus.$store.commit("INIT_GRP_ABOUT");
                thus.updateVocations([]);
                thus.$store.commit('SET_GRPTYPE', value);
                thus.loadGrpInfo(value);
                thus.form.schemes = [];
              }
            }
          })
        } else {
          this.loadGrpInfo(value)
        }
      },
      //根据行业获取职业信息
      loadGrpInfo(value){
        this.form.grpTypeCode = value[0];
        this.form.bussinessTypeCode = value[1];
        $.get("../api/commonQry/occupationQry?newGrpType=" + value[0] + "&newBussType=" + value[1], {}, (data) => {
          if (data.head.returnCode === "0") {
            this.$store.commit("CREATE_VOCATION_TYPES", data.occupationQry[0]);
          }
        }, 'json');
      },
      //行业变更提示
      //获取基本信息页面下拉单选数据
      getCascade(){
        $.ajax("../api/commonQry/baseInfoQry", {
          method: "get",
          contentType: "text/json;charset=UTF-8",
          success: (info) => {
            if (info.head.returnCode === "0") {
              this.bussSources = info.bussSource;
              this.intermediaryNames = info.intermediaryCode;
              this.grpNatures = info.grpNature
            }
          }
        })
      },
      //获取行业信息
      getTypeData(){
        $.ajax("../api/commonQry/busstypeQry", {
          method: "get",
          contentType: "text/json;charset=UTF-8",
          success: (info) => {
            if (info.head.returnCode === "0") {
              let ary = [];
              for (let i = 0; i < info.grpType.length; i++) {
                ary.push({
                  name: info.grpType[i].value,
                  value: info.grpType[i].id
                });
                if (info.grpType[i].child.length > 0) {
                  for (let k = 0; k < info.grpType[i].child.length; k++) {
                    ary.push({
                      name: info.grpType[i].child[k].value,
                      value: info.grpType[i].child[k].id,
                      parent: info.grpType[i].id
                    })
                  }
                }
              }
              this.grpTypeDatas = ary;

            }
          }
        })
      },
      //获取该版本特约信息
      getSpecialAppoints(){
        $.ajax("../ui/servlet/GCASServlet/special", {
          method: "post",
          contentType: "text/json;charset=UTF-8",
          success: (data) => {
            if(data.code === 400){
              this.vuxToast(data.data)
            }else{
              let info = JSON.parse(data);
              if (info.head.flag === "0") {
                let lists = info.body.ecspecialDetailDTOList;
                if (lists.length > 0) {
                  let appoints = [];
                  let appointsNames = ['一', '二', '三', '四', '五', '六'];
                  for (let i = 0; i < lists.length; i++) {
                    appoints.push({
                      key: Number(lists[i].specialRate),
                      value: '方案' + appointsNames[i],
                      inlineDesc: lists[i].special
                    })
                  }
                  this.$store.commit('GET_SPECIAL_APPOINTS', appoints)
                }
              } else {
                this.vuxToast('请求异常')
              }
            }
          }
        })
      },
      //查看职业信息
      viewStaffInfo(){
        if (this.form.insuredPeoples >= 3) {
          this.addStallTitle = "职业信息";
          this.staffInfoVisible = true
        } else {
          this.vuxToast('请预先填写被保人数');
        }
      },
      //职业信息页面相关
      updateVocations(info){
        this.form.vocations = info
      },
      clearSchemes(){
        this.form.schemes = []
      },
      //职业信息录入错误信息提示
      showStaffErrorInfo(info){
        this.vuxToast(info);
      },
      //计算既往赔付率
      getClaimRate(){
        let time = new Date();
        let obj = {
          head: {
            tranDate: time.toLocaleDateString(),
            tranTime: time.toLocaleTimeString(),
            tranNo: this.getUUid(),
            funcFlag: "mitMobile"
          },
          body: {
            companyName: this.form.customName
          }
        };
        $.ajax("../ui/servlet/GCASServlet/claimRate", {
          method: "post",
          contentType: "text/json;charset=UTF-8",
          data: JSON.stringify(obj),
          success: (info) => {
            let data = JSON.parse(info);
            if (data.head.flag === "0") {
              this.form.rate = "";
            } else {
              this.form.rate = ""
            }
          },
          error: () => {
            this.vuxToast('请求超时');
          }
        });
      },
      //判断六十周岁以上
      oldManSwitch(value){
        if (!value) {
          this.form.maxAge = "";
          this.form.sixtyPeoples = "";
        }
      },
      //判断是否共保
      coinsuranceSwitch(value){
        if (!value) {
          this.form.coinsuranceCompany = "";
          this.form.companyAmnt = "";
        }
      },
      //查看既往文本信息
      viewClaimNote(){
        this.showOldDetailInfo = true;
        this.claimNoteFlag = true;
      },
      //查看业务背景信息
      viewCompetePlan(){
        this.showOldDetailInfo = true;
        this.claimNoteFlag = false;
      },
      //关闭理赔记录以及业务背景文本域
      closeOldDetailPopup(){
        this.showOldDetailInfo = false
      },
      //新增、查看保险方案信息
      viewSchemes(){
        if (this.$store.state.app.vocations.length > 0) {
          this.$store.commit('SET_FORM_INFO', this.form);
          this.$vux.loading.show({
            text: '加载中'
          });
          setTimeout(() => {
            this.$vux.loading.hide();
            if (this.form.schemes.length > 0) {
              this.$store.commit('SET_SCHEMES_INFO', this.form.schemes);
              this.$router.push('/viewSchemes')
            } else {
              this.$router.push('/addScheme')
            }
            this.$store.commit('CHANGE_TRANSITION', 'left')
          }, 300)
        } else {
          this.vuxToast('请预先填写职业信息');
        }
      },
      //提交清单审核
      submitOrder(){
        let form = this.form;
        let vocations = form.vocations;
        let schemes = form.schemes;
        let occupationInfo = [];
        let insuredPlan = [];
        let specialAppoints = this.$store.state.app.allAppoints;
        if (schemes.length > 0) {
          for (let i = 0; i < vocations.length; i++) {
            occupationInfo.push({
              occupationCode: vocations[i].occupationCode.toString(),
              occupationNms: vocations[i].occupationNms.toString()
            })
          }
          for (let k = 0; k < schemes.length; k++) {
            let scheme = schemes[k];
            let riskDuties = [];
            let claims = ["3%-5%-7%", "5%-10%-15%", "10%-12%-18%", "10%-20%-30%"];
            if (scheme.duties.length > 0) {
              let rule = (a, b) => Number(a.dutyCode) - Number(b.dutyCode);
              scheme.duties.sort(rule);
              for (let s = 0; s < scheme.duties.length; s++) {
                let duty = scheme.duties[s];
                riskDuties.push({
                  dutyCode: duty.dutyCode,
                  amnt: duty.amnt.toString(),
                  disableAsstandard: duty.disableAsstandard.toString(),
                  claimRateA: duty.industryPaymentProp !== "" ? claims[duty.industryPaymentProp - 1] : '10%-20%-30%',
                  claimRateB: duty.jobPaymentProp !== "" ? claims[duty.jobPaymentProp - 1] : '10%-20%-30%',
                  standprem: duty.standardPremium.toString(),
                  prem: duty.currentPremium.toString(),
                  deductibleDats: duty.deductibleDats,
                  deductible: duty.deductible,
                  deductibleRate: duty.deductibleRate,
                  premiumRate: duty.premiumRate.toString()
                })
              }
            }
            let appoints = [];
            for(let i=0;i<specialAppoints.length;i++){
              for(let k=0;k<scheme.specialAppoints.length;k++){
                if(scheme.specialAppoints[k] === specialAppoints[i].key){
                  appoints.push(specialAppoints[i].inlineDesc)
                }
              }
            }
            insuredPlan.push({
              insuredTarget: scheme.insuredTarget,
              targetName: scheme.targetName,
              planId: k.toString(),
              occupationType: scheme.occupationType,
              peoples: scheme.peoples.toString(),
              avgAges: scheme.avgAges.toString(),
              insuredYear: scheme.insuredLength.toString(),
              insuredYearFlag: scheme.insuredFlag,
              riskPlan: riskDuties,
              specialAppoints:appoints
            })
          }
          this.$vux.loading.show({
            text: '审核中'
          });
        } else {
          this.vuxToast('请填写保险方案');
          return
        }
        let time = new Date();
        let obj = {
          head: {
            tranDate: time.toLocaleDateString(),
            tranTime: time.toLocaleTimeString(),
            tranNo: this.getUUid(),
            funcFlag: "mitMobile"
          },
          body: {
            bussinessInfo: {
              bussSource: form.bussSourceCode,
              serviceRate: form.serviceRate !== "" ? (Math.round(form.serviceRate) / 100).toString() : "",
              operater: this.$store.state.app.loginInfo ? this.$store.state.app.loginInfo.workNumber : this.$store.state.app.workNumber,
              intermediaryCode: form.intermediaryCode
            },
            customInfo: {
              customName: form.customName,
              grpNature: form.grpNatureCode,
              grpType: form.grpTypeCode,
              bussinessType: form.bussinessTypeCode
            },
            personInfo: {
              insuredPeoples: form.insuredPeoples.toString(),
              inAvage: form.inAvage.toString(),
              isSixtyPeopleFlag: form.isSixtyPeopleFlag ? "0" : "1",
              maxAge: form.maxAge.toString(),
              sixtyPeoples: form.sixtyPeoples.toString(),
              males: form.males.toString(),
              females: form.females.toString(),
              spouser: form.spouser.toString(),
              children: form.children.toString(),
              occupationInfo: occupationInfo
            },
            backInfo: {
              preproposalCarp: form.preproposalCarp,
              claimNote: form.claimNote,
              backCliamRate: form.rate.toString(),
              competePlan: form.competePlan
            },
            insuredPlanInfo: {
              coinsuranceFlag: form.coinsuranceFlag ? "0" : "1",
              coinsuranceCompany: form.coinsuranceCompany,
              companyAmnt: form.companyAmnt.toString(),
              insuredPlan: insuredPlan
            }
          }
        };
        $.ajax("../ui/servlet/GCASServlet/submite", {
          method: "post",
          contentType: "text/json;charset=UTF-8",
          data: JSON.stringify(obj),
          success: (data) => {
            this.$vux.loading.hide();
            let info = JSON.parse(data);
            if (info.flag === "0") {
              this.vuxToast(info.desc);
            } else if (info.flag === "1") {
              let flag = true;
              let obj = {
                status: flag,
                riskAssessNo: info.riskAssessNo,
                reasonNotes:null
              };
              this.$store.commit('SET_SUBMIT_RESULT', obj);
              this.$router.push('/resultPage');
              this.$store.commit('CHANGE_TRANSITION', 'left')
            } else {
              let flag = false;
              let obj = {
                status: flag,
                riskAssessNo: info.riskAssessNo,
                reasonNotes:info.rereviewedDTOList
              };
              this.$store.commit('SET_SUBMIT_RESULT', obj);
              this.$router.push('/resultPage');
              this.$store.commit('CHANGE_TRANSITION', 'left')
            }
          },
          error: () => {
            this.$vux.loading.hide();
            this.vuxToast('请求超时');
          }
        })
      }
    },
    mounted(){
      this.ios = this.$store.state.app.ios;
      let state = this.$store.state.app;
      if (state.currentIndex) {
        this.currentStep = state.currentIndex;
        this.form = state.formInfo;
        this.form.schemes = state.schemes
      }
      this.getCascade();
      this.getTypeData();
      this.getSpecialAppoints()
    }
  }
</script>
